import { request } from '@/utils'

export default {
    namespaced: true,
    state: {
        loading: false,
        data: []
    },
    mutations: {
        set_loading(state, payload) {
            state.loading = payload
        },
        set_data(state, payload) {
            state.data = payload
        }
    },
    actions: {
        async get_data(ctx) {
            if (ctx.state.data.length) {
                return;
            }
            ctx.commit('set_loading', true)
            const resp = await request.get('/api/project')
            ctx.commit('set_data', resp)
            ctx.commit('set_loading', false)
        }
    }
}
